package com.bjpowernode.controller;

import com.bjpowernode.entity.TActivityRemark;
import com.bjpowernode.query.ActivityQuery;
import com.bjpowernode.query.ActivityRemarkQuery;
import com.bjpowernode.result.Result;
import com.bjpowernode.service.ActivityRemarkService;
import com.github.pagehelper.PageInfo;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequiredArgsConstructor
public class ActivityRemarkController {

    private final ActivityRemarkService activityRemarkService;

    /**
     * 添加市场活动备注
     */
    @PostMapping("api/activity/remark")
    public Result addActivityRemark(@RequestBody ActivityRemarkQuery activityRemarkQuery) {
        int row = activityRemarkService.saveActivityRemark(activityRemarkQuery);

        return row >= 1 ? Result.OK():Result.FAIL();
    }

    /**
     * 分页查询市场活动备注
     */
    @GetMapping("api/activity/remarks")
    public Result getActivityRemarkByPage(Integer current, Integer activityId) {
        PageInfo<TActivityRemark> pageInfo = activityRemarkService.getActivityRemarkByPage(current,activityId);
        return Result.OK(pageInfo);
    }
}
